import { rawRequestClient } from '#/api/request';

// 渠道账号接口类型定义
export interface ChannelAccount {
  id?: number;
  name: string;
  account_id: string;
  channel_id: number;
  channel_name?: string;
  api_key: string;
  organization_id: string;
  tier: number;
  charge_type: number;
  total_amount: number;
  used_amount: number;
  remaining_amount: number;
  amount_currency: number;
  is_enabled: boolean;
  created_at?: string;
  created_by?: string;
  updated_at?: string;
  updated_by?: string;
}

// 获取渠道账号列表
export function getChannelAccountList(params?: {
  page?: number;
  size?: number;
  name?: string;
  channel_id?: number;
  channel_type?: string;
  account_id?: string;
  tier?: number;
  is_enabled?: boolean;
}) {
  console.log(  'sssssssssssssss:',  `${import.meta.env.VITE_MODEL_LAKE_SERVER}/management/channel-accounts`);
  return rawRequestClient.get(`${import.meta.env.VITE_MODEL_LAKE_SERVER}/management/channel-accounts`, { params });
}

// 创建渠道账号
export function createChannelAccount(data: Omit<ChannelAccount, 'id' | 'created_at' | 'created_by' | 'updated_at' | 'updated_by' | 'channel_name'>) {
  return rawRequestClient.post(`${import.meta.env.VITE_MODEL_LAKE_SERVER}/management/channel-accounts`, data);
}

// 获取渠道账号详情
export function getChannelAccountDetail(id: number) {
  return rawRequestClient.get(`${import.meta.env.VITE_MODEL_LAKE_SERVER}/management/channel-accounts/${id}`);
}

// 更新渠道账号
export function updateChannelAccount(id: number, data: Omit<ChannelAccount, 'id' | 'created_at' | 'created_by' | 'updated_at' | 'updated_by' | 'channel_name'>) {
  return rawRequestClient.put(`${import.meta.env.VITE_MODEL_LAKE_SERVER}/management/channel-accounts/${id}`, data);
}

// 删除渠道账号
export function deleteChannelAccount(id: number) {
  return rawRequestClient.delete(`${import.meta.env.VITE_MODEL_LAKE_SERVER}/management/channel-accounts/${id}`);
}
